home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2 (Special) / PCPro-2b.iso / Demos / Macromedia / CourseBuilder / CourseBuilderInstaller.exe / Disk1 / data1.cab / Dreamweaver-unInstalled / Configuration / Commands / Name Editor.js < prev    next >
Encoding:
JavaScript  |  1999-12-06  |  1.6 KB  |  78 lines

  1. // Copyright 1999 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. var HELP_DOC = HELP_cmdNameEditor;
  6.  
  7. var THE_NAME = '';
  8. var IS_SET = false;
  9. var HANDLE_EXT = false;
  10.  
  11.  
  12. //******************* API **********************
  13.  
  14. function commandButtons(){
  15.   return new Array(BTN_OK,"cmdOK()",
  16.                    BTN_Cancel,"cmdCancel()",
  17.                    BTN_Help,"displayHelp()");
  18. }
  19.  
  20. function cmdOK() {
  21.   if (applyCommand()) {
  22.     garbageCollect(true);
  23.     window.close();
  24.   }
  25. }
  26.  
  27. function cmdCancel() {
  28.   garbageCollect(true);
  29.   window.close();
  30. }
  31.  
  32. function applyCommand() {
  33.   if (THE_NAME) {
  34.     IS_SET = true;
  35.     return true;
  36.   } else {
  37.     alert(MSG_enterName);
  38.     return false;
  39.   }
  40. }
  41.  
  42. function inspectCommand(theName, isCondOrSeg){
  43.   THE_NAME = theName;
  44.   IS_SET = false;
  45.   HANDLE_EXT = isCondOrSeg;
  46. }
  47.  
  48. //***************** LOCAL FUNCTIONS  ******************
  49.  
  50. function initializeUI(){
  51.   var theObj;
  52.   
  53.   theObj=findObject('theName');
  54.   if (HANDLE_EXT && theObj)
  55.     theObj.value = removeExt(THE_NAME);
  56.   else
  57.     theObj.value = THE_NAME;
  58.     
  59.   document.theForm.theName.focus();
  60.   document.theForm.theName.select();
  61. }
  62.  
  63. function updateUI(theItemName) {
  64.   var theObj;
  65.   
  66.   theObj = findObject(theItemName);
  67.   if (theObj) {
  68.     if (theItemName == 'theName' && 
  69.         (!HANDLE_EXT || removeExt(THE_NAME) != theObj.value) )  {
  70.       THE_NAME = theObj.value;
  71.       THE_NAME = replaceSub(THE_NAME, '"', '');
  72.       THE_NAME = replaceSub(THE_NAME, "'", '');
  73.       theObj.value = THE_NAME;
  74.     }
  75.   }
  76. }
  77.  
  78.